/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.timesoft.zk.common.message;

import com.timesoft.zk.common.ResourceUtil;
import org.zkoss.zul.Messagebox;

/**
 *
 * @author sorasaks
 */
public class AlertMessages
{
    public static int YES = Messagebox.YES;
    public static int NO = Messagebox.NO;
    public static int CANCEL = Messagebox.CANCEL;
    public static int OK = Messagebox.OK;
    public static int ABORT = Messagebox.ABORT;
    public static int IGNORE = Messagebox.IGNORE;
    public static int RETRY = Messagebox.RETRY;

    public static int alertMessage(String messageCode)
    {
       return alertMessage(messageCode,null);
    }

    public static int alertMessage(String messageCode,String messageHeader)
    {
       return alertMessage(messageCode,messageHeader,null);
    }

    public static int alertMessage(String messageCode,String messageHeader,String icon)
    {
       return showMessage(messageCode,((messageHeader==null || messageHeader.trim().isEmpty())?"default.alert.message.title":messageHeader),Messagebox.OK,(icon==null || icon.trim().isEmpty())?Messagebox.INFORMATION:icon);
    }

    public static int confirmMessage(String messageCode)
    {
       return confirmMessage(messageCode,"default.alert.message.title",Messagebox.QUESTION);
    }

    public static int confirmMessage(String messageCode,String messageHeader)
    {
       return confirmMessage(messageCode,messageHeader,Messagebox.QUESTION);
    }

    public static int confirmMessage(String messageCode,String messageHeader,String icon)
    {
       return showMessage(messageCode,((messageHeader==null || messageHeader.trim().isEmpty())?"default.alert.message.title":messageHeader),Messagebox.YES|Messagebox.NO,(icon==null || icon.trim().isEmpty())?Messagebox.QUESTION:icon);
    }


    private static int showMessage(String messageCode,String messageHeader, int buttons,String icon)
    {
        try {
               return Messagebox.show(ResourceUtil.getLabel(messageCode),ResourceUtil.getLabel(messageHeader) , buttons, icon);
        } catch (Exception ex) {
        }
        return 0;
    }
}